import axios, {AxiosError} from "axios";
import {onMounted, reactive} from "vue";


export default function () {
    let imageList = reactive<string[]>([]);

    onMounted(() => {
        console.log("xxx");
    });

//   "https://dog.ceo/api/breed/pembroke/images/random"

    async function addImage() {
        try {
            let {data} = await axios.get(
                "https://dog.ceo/api/breed/pembroke/images/random"
            );
            console.log("{data} 解构:", data);
            imageList.push(data.message);
        } catch (error) {
            const e = <AxiosError>error;
            console.log("请求异常:", e.message);
        }
    }


    onMounted(() => {
        addImage();
    })

    return {
        imageList,
        addImage
    }

}